# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Maintainer: Orhun Parmaksız <orhun@archlinux.org>
# Contributor: Carlo Cabanilla <carlo.cabanilla@gmail.com>
# Contributor: Christoph Gysin <christoph.gysin@gmail.com>

pkgname=aws-vault
pkgver=7.2.0
pkgrel=1
pkgdesc='Vault for securely storing and accessing AWS credentials in development environments'
url='https://github.com/99designs/aws-vault'
arch=('loong64' 'x86_64')
license=('MIT')
depends=('glibc')
makedepends=('go')
optdepends=(
  'zenity: graphical prompt'
  'kdialog: graphical prompt'
)
source=("${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz")
sha256sums=('3f2f1d0ec06eb0873f9b96b59dc70f9fcc832dc97b927af3dbab6cdc87477b0e')
b2sums=('88686d77e5624f5c9d6c62b661ad022088505b19904da664eb397fe42a78b46f92bf859ea311efc50865673d08f632a3a37d42dced9f0a52fad264da9b3f5cbf')

build() {
  cd "${pkgname}-${pkgver}"
  export CGO_CFLAGS="${CFLAGS}"
  export CGO_CXXFLAGS="${CXXFLAGS}"
  export CGO_CPPFLAGS="${CPPFLAGS}"
  export CGO_LDFLAGS="${LDFLAGS}"
  export GOFLAGS="-buildmode=pie -ldflags=-linkmode=external -trimpath -mod=readonly -modcacherw"
  go build -v \
    -ldflags "-linkmode=external -extldflags '${LDFLAGS}' -X main.Version=v${pkgver}" .
}

check() {
  cd "${pkgname}-${pkgver}"
  go test ./...
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm 755 ${pkgname} -t "${pkgdir}/usr/bin"
  install -Dm 644 README.md USAGE.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -Dm 644 -p contrib/completions/bash/${pkgname}.bash "${pkgdir}/usr/share/bash-completion/completions/${pkgname}"
  install -Dm 644 -p contrib/completions/zsh/${pkgname}.zsh "${pkgdir}/usr/share/zsh/site-functions/_${pkgname}"
  install -Dm 644 -p contrib/completions/fish/${pkgname}.fish "${pkgdir}/usr/share/fish/vendor_completions.d/${pkgname}.fish"
}

# vim: ts=2 sw=2 et:
